<template>
  <div>
    <div v-if="" class="comments_item" >
      <div class="left">
        <img :src="item.user.avatarUrl" alt="" />
      </div>
      <div class="right">
        <div class="author_msg">
          <div class="author_name">{{item.user.nickname}}</div>
          <div class="author_time">2020年12月01日</div>
        </div>
        <div class="comments">
          {{item.content}}
        </div>
        <div @click="handleShowComments" v-if="item.beReplied?item.beReplied.length>0?true:false:false" class="reply_text">
            {{item.beReplied.length}}条回复
        </div>
      </div>
    </div>
    <slot  v-if="nowIndex===commentIndex" name="subComments"></slot>
  </div>
</template>

<script>
export default {
  props: ["item","index"],
  data() {
    return {
        nowIndex:null,
        commentIndex:this.index,
    };
  },
  mounted(){
    //   console.log(this.item)
  },
  methods:{
      handleShowComments(){
          this.nowIndex = this.commentIndex;
          this.$emit('getIndex',this.nowIndex)
      },
      handleClose(){
          this.nowIndex = null;
      }
  },
  watch: {
    
  },
};
</script>

<style lang="less" scoped>
.comments_item {
        display: flex;
            padding: 0 0.3rem;
  .left {
    img {
      width: 1rem;
      border-radius: 50%;
      overflow: hidden;
    }
  }
  .right {
          padding: 0.2rem;
    .author_msg {
      height: 1rem;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      .author_name {
        font-size: 0.3rem;
        font-weight: bold;
      }
    }
    .comments {
        line-height: 1.8;
      }
      .reply_text{
               color: #6b6bb4;
               padding: 0.2rem 0;
               letter-spacing: 0.02rem;
        }
  }
}
</style>